//
//  CZEmoticonButton.swift
//  Weibo24
//
//  Created by apple on 16/3/8.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit
/*
    面向对象的三大特性:
    封装/继承/多态
*/
class CZEmoticonButton: UIButton {

    var emoticon: CZEmoticon?{
    
        didSet{
        
            //显示图片表情
            if let png = emoticon?.png {
                
                let imagePath = "\(emoticon!.path!)/\(png)"
                
                self.setImage(UIImage(named: imagePath), forState: UIControlState.Normal)
                self.setTitle(nil, forState: UIControlState.Normal)
                
                //使用他的时候,再显示
                self.hidden = false
            }
            // 显示emoji
            if let emoji = emoticon?.emoji {
                
                self.setImage(nil, forState: UIControlState.Normal)
                
                self.setTitle(emoji, forState: UIControlState.Normal)
                //使用他的时候,再显示
                self.hidden = false
                
                //修改titlelabel
                self.titleLabel?.font = UIFont.systemFontOfSize(38)
            }
            
        }
        
    }

    
}
